package com.jijia.webbase.config.websocket;

import com.jijia.webbase.interception.websocket.WebsocketInterceptionForConfig;
import com.jijia.webbase.websocket.myWebSocketHandler;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.socket.config.annotation.EnableWebSocket;
import org.springframework.web.socket.config.annotation.WebSocketConfigurer;
import org.springframework.web.socket.config.annotation.WebSocketHandlerRegistry;

////启用websocket方式2
@Configuration
@EnableWebSocket
public class WebSocketConfigForConfig implements WebSocketConfigurer {
    @Override
    public void registerWebSocketHandlers(WebSocketHandlerRegistry registry) {
        registry.addHandler(new myWebSocketHandler(), "/chat")
                .addInterceptors(new WebsocketInterceptionForConfig())
                .setAllowedOrigins("*");
    }
}
